<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Interpreter Tests</title>
</head>
<body>
<h1>Interpreter Tests</h1>
<p>Crunchy allows embedding a number of Python interpreters in
a given html page. All the interpreters share a common environment,
which means that variables defined in one interpreter do not
have to be redefined in an other one.</p>
<p>The following is a sample interpreter session; verify that the
output is as expected:</p>
<pre title="interpreter">
>>> # simple evaluation:
>>> 7*6
42
>>> # handling spaces:
>>> 7 * 6
42
>>> # assignment:
>>> x = 7*6
>>> print x
42
>>> # tooltip; type slowly and observe the "popup tooltip"
>>> # appearing when typing "(" and disappearing with ")": 
>>> range(5)
[0, 1, 2, 3, 4]
>>> # auto-indent (use backspace to create the blank line at the end): 
>>> for y in range(5):
...     print y,
... 
0 1 2 3 4
</pre>

<p>Here are a few more examples (with added linenumbers):</p>
<pre title="interpreter linenumber">
>>> # undefined variable
>>> print a
Error on line 1:
 name 'a' is not defined
>>> # however, previously defined variables should be remembered
>>> print x
42
>>> #the following should not actually exit, but instead catch the error; 
>>> # the error message could be improved upon!
>>> # also note that a tooltip appears when typing "."
>>> import sys
>>> sys.exit()
Error on line 1:

</pre>

<h2>Bugs</h2>
<ul>
<li>Note that an interpreter session that ends with a comment, as in:
<pre>
>>> # this last statement is a comment
</pre>
is currently processed by crunchy ("colourized") in such a way
that it results in non W3C compliant code - and Crunchy (i.e. the
elementtree handler) chokes on it, and displays a blank page.  This should be fixed. 
(<a href="interpreter_comment_bug.html">Here is a page to test it</a>).</li>
<li>Code inside a <code>&lt;pre&gt;</code> that contains html markup is
not processed properly.  The suggested behaviour at this point would be to 
[1.] convert all <code>&lt;br&gt;</code> or <code>&lt;br/&gt;</code> 
into <code>\n</code> and 
[2.] to strip the remaining html markup.</li>
<li>Comments and linenumbers apparently don't mix properly (overlapping
<code>&lt;span&gt;</code> sometimes result in a small interpreter prompt
(i.e. in the same font size as the linenumber).</li>
<li>
The following should result in an error message, but there's simply no 
output given.
<pre title="interpreter">
>>> for i in range(4):
...     print a  # undefined variable
</pre>

</li>
</ul>
<p><a href="index.html">Back to the test index</a></p>
</body>
</html>
